

    function [output] = oneth_order_sigma_delta_ciff(X,bit_lev,vref)


        global fixed_point_cfg;


        dataLen = length(X);


        y  = zeros(1, dataLen);
        Yprev = 0;


        for n = 1 : dataLen

            if(n > 1)
                y(n) = X(n-1)*0.5 - output(n-1) + y(n-1);

            else
                y(n) = X(n)*0.5 - Yprev + 0;

            end

            % if(y(n) >= 1)
            %     output(n) = 1;
            % else
            %     if(y(n) <= -1)
            %         output(n) = -1;
            %     else
            %         output(n) = 0;
            %     end
            % end
            output_step = (2*vref) / (2^(bit_lev)-1);

            output(n) = round(y(n) / output_step);
            if(output(n) > (2^(bit_lev-1) -1) )
                output(n) = 2^(bit_lev-1) -1;
            end
            if(output(n) < (-(2^(bit_lev-1) -1)) )
                output(n) = -(2^(bit_lev-1)-1);
            end

            Yprev = output(n)*output_step;
        end

    end

